﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using CAOS.Entity.Validation;

namespace CAOS.Entity
{
    [Table("SISTEMA")]
    [MetadataType(typeof(SistemaMetaData))]
    public class Sistema : ICAOSEntity
    {
        public Sistema()
        {
            this.Papeis = new List<Papel>();
        }

        [Key]
        [Column("SIST_SQ_SISTEMA")]
        public int SistemaID { get; set; }

        [Column("SIST_TX_SIGLA")]
        public string Sigla { get; set; }

        [Column("SIST_NM_NOME")]
        public string Nome { get; set; }

        [Column("SIST_DT_CADASTRO")]
        public DateTime? DataCadastro { get; set; }

        [Column("SIST_CD_CODIGO_AUTENTICACAO")]
        public string CodigoAutenticacao { get; set; }

        public virtual IList<Papel> Papeis { get; set; }

        public override bool Equals(object obj)
        {
            Sistema sis = obj as Sistema;

            if (sis == null)
            {
                return false;
            }

            return sis.SistemaID == this.SistemaID;
        }

        public override int GetHashCode()
        {
            return this.SistemaID.GetHashCode();
        }
    }
}
